package com.ostrich.note.ui.settings.views;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;

import android.os.Bundle;
import android.view.View;

import com.ostrich.note.R;
import com.ostrich.note.base.BaseActivity;
import com.ostrich.note.databinding.ActivitySettingsDraftBinding;
import com.ostrich.note.room.AppDataBase;
import com.ostrich.note.room.Note;
import com.ostrich.note.room.NoteDao;
import com.ostrich.note.ui.note.adapter.NoteAdapter;
import com.ostrich.note.ui.settings.adapter.NoteDraftAdapter;

import java.util.List;

public class SettingsDraftActivity extends BaseActivity<ActivitySettingsDraftBinding> {

    private NoteDao mNoteDao;
    private NoteDraftAdapter mNoteDraftAdapter;
    @Override
    protected void iniView() {
        mNoteDao = AppDataBase.getInstance().getNoteDao();
    }

    @Override
    public int getLayout() {
        return R.layout.activity_settings_draft;
    }

    @Override
    public void initData() {
        List<Note> notes = mNoteDao.selectAll();
        mNoteDraftAdapter = new NoteDraftAdapter();
        binding.rv.setAdapter(mNoteDraftAdapter);
        binding.rv.setLayoutManager(new LinearLayoutManager(this));
        mNoteDraftAdapter.setData(notes);

    }

    @Override
    public void initListener() {
        binding.clBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
}